# koroFileHeader at Yungoal acer
# Create: 2021-09-03 09:26:56
# LastEdit: 2021-09-03 09:54:48
"""https://leetcode-cn.com/problems/plus-one/"""
__author__ = '749B'

from typing import List

class Solution:
    def plusOne(self, digits: List[int]) -> List[int]:
        for i in range(len(digits))[::-1]:
            digits[i] += 1
            if digits[i] == 10:
                digits[i] = 0
            else:
                return digits
        if digits[0] == 0:
            digits.insert(0, 1)
        return digits


    def plusOne0(self, digits: List[int]) -> List[int]:
        digits_str = [str(d) for d in digits]
        num = int(''.join(digits_str))
        num += 1
        s = str(num)
        return [int(j) for j in s]


if __name__ == "__main__":
    digits = [1, 2, 3]
    res = Solution().plusOne0(digits)
    print(res)
